<?php
namespace EasyVote\EasyVoteBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;
use EasyVote\EasyVoteBundle\Entity\Job;

/**
 * Class LoadJobData
 * Loads the job information
 * @package EasyVote\EasyVoteBundle\DataFixtures\ORM
 */
class LoadJobData extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * {@inheritDoc}
     */
    public function load(ObjectManager $manager)
    {
        $dept_mgr = $manager->getRepository('EasyVoteBundle:Department');

        $cs = $dept_mgr->findOneByName('Department of Computer Science and Engineering');
        $cs_prof = new Job();
        $cs_prof->setName('CS Professor');
        $cs_prof->setDescription('CS Professor');
        $cs_prof->setDepartment($cs);
        $manager->persist($cs_prof);
        $manager->flush();

        $cs_student = new Job();
        $cs_student->setName('CS Student');
        $cs_student->setDescription('CS Student');
        $cs_student->setDepartment($cs);
        $manager->persist($cs_student);
        $manager->flush();

    }

    /**
     * {@inheritDoc}
     */
    public function getOrder()
    {
        return 4; // the order in which fixtures will be loaded
    }
}

?>
